Skip to content

fix(web): report ChatGPT sign-in returns to removed environments - #39573

Open
StiensWout wants to merge 7 commits into
pingdotgg:mainfrom
StiensWout:t3/1246-chatgpt-sign-in-returns-silently-when-it
Open

StiensWout wants to merge 7 commits into
pingdotgg:mainfrom
StiensWout:t3/1246-chatgpt-sign-in-returns-silently-when-it

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Browser ChatGPT sign-in returns waited silently for removed environments. The browser now shows the existing error when the destination is absent from the loaded catalog and platform discovery has resolved the topology, even if an unrelated persistence write fails. Incomplete discovery keeps the callback available for delivery when its environment connects.

Fixes #39572
Related: #29125

Reproduction on main

Commit 59651c1761 (main). T3 Code opens Welcome for another environment without reporting that the sign-in failed. The cause is at apps/web/src/providerAuthDelivery.ts:33. Ran pnpm scenarios:prove scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts --base main with the repro test added: it failed in 2 of 2 runs on a clean checkout, with ChatGPT sign-in couldn't finish in the output.

Evidence

Environment: boat.dev default machine, Linux x64, a fresh checkout of each commit

Steps: A ChatGPT sign-in return reports that it cannot finish on a removed environment: app.open ; expect.not.toHaveURL //pair(?:[?#]|$)/; app.open /welcome#codex-auth=%7B%22environmentId%22%3A%22removed-sign-in-machine%22%2C%22instanceId%22%3A%22codex%22%2C%22flowId%22%3A%22scenario-flow%22%2C%22callbackUrl%22%3A%22http%3A%2F%2F127.0.0.1%3A1455%2Fauth%2Fcallback%3Fstate%3Dscenario-auth-state%26code%3Dscenario-code%22%2C%22returnHash%22%3A%22%23agents%3Aremoved-sign-in-machine%22%7D; expect.toBeVisible getByText("ChatGPT sign-in couldn't finish"); app.screenshot return-to-removed-environment.

Proven: the scenario fails on base d6cdb4f161 and passes on head 4b00217a11.

Before After
Commit d6cdb4f161 4b00217a11
Result Fails: ASSERTION_FAILED: expect.toBeVisible failed Passes
return to removed environment Before: return to removed environment After: return to removed environment
failure Before: failure
Recording Before: Recording After: Recording
Scenario source: scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts
import { EnvironmentId, ProviderInstanceId } from "@t3tools/contracts";
import { codexAuthDeliveryUrl } from "@t3tools/shared/codexAuthHandoff";
import { expect } from "e2e";

import { test, WEB } from "./t3.ts";

test(
  "A ChatGPT sign-in return reports that it cannot finish on a removed environment",
  WEB,
  async ({ t3, app, screen }) => {
    await t3.project("demo");
    const environmentId = EnvironmentId.make("removed-sign-in-machine");
    const instanceId = ProviderInstanceId.make("codex");
    const returnUrl = new URL("/welcome", app.baseUrl);
    returnUrl.hash = `agents:${environmentId}`;

    // Start at the helper's return link. The missing machine makes the code unusable,
    // so this does not contact the identity provider.
    const callback = new URL("http://127.0.0.1:1455/auth/callback");
    callback.searchParams.set("state", "scenario-auth-state");
    const authorization = new URL("https://auth.openai.com/api/accounts/authorize");
    authorization.search = new URLSearchParams({
      state: "scenario-auth-state",
      redirect_uri: "http://127.0.0.1:1455/auth/callback",
      response_type: "code",
      code_challenge_method: "S256",
      code_challenge: "a".repeat(43),
      client_id: "dynamic_agent_client",
    }).toString();
    callback.searchParams.set("code", "scenario-code");
    const delivery = new URL(
      codexAuthDeliveryUrl(
        {
          authorizationUrl: authorization.href,
          returnUrl: returnUrl.href,
          environmentId,
          instanceId,
          flowId: "scenario-flow",
        },
        callback.href,
      ),
    );
    await t3.open(`${delivery.pathname}${delivery.search}${delivery.hash}`);
    try {
      await expect(
        screen.getByText("ChatGPT sign-in couldn't finish", { exact: true }),
      ).toBeVisible();
    } finally {
      await app.screenshot("return-to-removed-environment");
    }
  },
);

Tests

  • ecc4522788 adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed passed on head.

Not in this change

  • Saved targets still wait through transient disconnects, and the connection supervisor retains its policies for disabled and unsupported entries.
  • Removal after callback dispatch follows existing RPC error handling.
  • Exact environment IDs still select the destination, regardless of duplicate labels, route changes, or provider IDs.
  • Empty and malformed fragments follow the existing parser and URL cleanup.
  • Each page consumes one return fragment, and the server still validates flows and orders returns across tabs.
  • Desktop and native mobile sign-in use separate callback paths.
  • Configured split-origin primaries use the same discovery gate as same-origin primaries, which the browser scenarios exercise.

Who did the work

  • Written by GPT 6.2 Sol, in Codex
  • Review findings fixed by GPT 6.2 Sol, in Codex
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, each on its own
  • Also reviewed by cubic, run locally by a program, with no score
  • Reproduction, checks and proof run by a program on base and head, not by an agent
  • Left open after review: should, apps/web/src/providerAuthDelivery.ts:40: On a loopback web client, a return to a removed remote environment can still stay silent if the unrelated primary descriptor request keeps failing. I reproduced the dependency by loading a return for an ID absent from the catalog and aborting two consecutive primary descriptor requests. The error toast appeared only after I let primary discovery succeed. The registry publishes null on every incomplete poll, and this atom waits indefinitely on null. When a target's identity is known, limit discovery uncertainty to the IDs it could affect. For discovery that remains unresolved, give the user feedback after a bounded wait while continuing to accept recovery for a valid callback.; should (cubic), apps/web/src/connection/platform.ts:765: One failing desktop-local backend keeps sign-in returns waiting forever. discoveryComplete goes false whenever any secondary bootstrap is rejected or fails to load, and also when the primary topology read fails. While that is true, entriesAfterPlatformDiscovery emits null. Take a desktop with one broken or rejected secondary backend: every poll reports incomplete, so a ChatGPT return addressed to a removed environment stays AsyncResult.initial() in providerAuthDelivery.ts and never shows the error toast. That is the silent failure this branch is meant to fix. Discovery could count as complete once each target has been tried once, or it could only block when the delivery's own environment might be the unresolved one.

Made in T3 Code by Claude Opus 5.5 and GPT 6.2 Sol

StiensWout and others added 5 commits November 20, 2026 08:24
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Platform connection sources now publish registration snapshots with discovery status. The registry exposes catalog entries after discovery. Provider auth delivery waits for discovery and reports when the destination environment is unavailable.

Changes: Environment discovery and auth delivery

Layer / File(s) Summary
Platform snapshots and registry state
packages/client-runtime/src/platform/source.ts, packages/client-runtime/src/connection/registry.ts, apps/web/src/connection/platform.ts, apps/mobile/src/connection/platform.ts, packages/client-runtime/src/connection/layer.ts, packages/client-runtime/src/connection/registry.test.ts, packages/client-runtime/src/state/threads-atoms.test.ts
Platform sources now publish registrations with a discovery-completion flag. The registry tracks that state and exposes catalog snapshots only after discovery completes. Startup reconciliation and registry test support use the updated contract.
Provider auth destination handling
apps/web/src/connection/catalog.ts, apps/web/src/providerAuthDelivery.ts, scripts/scenarios/chatgpt-return-reaches-primary-environment.e2e.ts, scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts
The web app exposes the registry’s discovery stream through an atom. Provider auth delivery waits for discovery and destination connection, and reports when discovery excludes the destination. End-to-end scenarios cover interrupted discovery and removed environments.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: juliusmarminge, maria-rcks, shivamhwp

Merge Risk: Minimal · up to ae3ff

This change shows the sign-in failure message when a ChatGPT return targets a removed environment. It keeps waiting while platform discovery is incomplete. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title follows conventional commit form and names the main change: the browser now reports ChatGPT sign-in returns that target removed environments. It matches the changeset, which adds discovery-g…
Description check Passed The description covers the problem, the change, the scope link to issue #39572, and verification. It includes reproduction steps, before/after evidence, and a test commit. It also lists exclusions and…
Linked Issues check Passed Directly linked issue #39572 requires that a ChatGPT sign-in return for a removed environment shows that sign-in could not finish. At head ae3ff16, apps/web/src/providerAuthDelivery.ts reads entriesAf…
Out of Scope Changes check Passed The changes in the whole-PR summary (merge base de0466f to head ae3ff16) implement the discovery-gated missing-environment check. They touch apps/web/src/providerAuthDelivery.ts, apps/web/src/connect…
Full details: Title check

Explanation

The title follows conventional commit form and names the main change: the browser now reports ChatGPT sign-in returns that target removed environments. It matches the changeset, which adds discovery-gated error reporting in providerAuthDelivery and related registry and platform changes.

Full details: Description check

Explanation

The description covers the problem, the change, the scope link to issue #39572, and verification. It includes reproduction steps, before/after evidence, and a test commit. It also lists exclusions and author attribution, which go beyond the template but do not conflict with it. The Problem section is merged into the opening paragraph, and the Scope section links the issue, so the required information is present. The verification section gives observed results for the changed behavior, and the description is mostly complete.

Full details: Linked Issues check

Explanation

Directly linked issue #39572 requires that a ChatGPT sign-in return for a removed environment shows that sign-in could not finish. At head ae3ff16, apps/web/src/providerAuthDelivery.ts reads entriesAfterPlatformDiscoveryAtom from apps/web/src/connection/catalog.ts. When discovery is resolved and the destination ID is absent from the catalog, the destination atom yields "missing", and reportUnavailableEnvironment() shows the toast "ChatGPT sign-in couldn't finish". When the presentation is known, the flow waits for the connected phase and does not report an error. The scenario scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts fails on base d6cdb4f and passes on head 4b00217, per the PR description. The registry (packages/client-runtime/src/connection/registry.ts) keeps discovery state separate from persistence writes, and the added registry test covers a failed bearer credential save. The issue's stated reproduction is met. Known gap: when discovery stays incomplete (the PR cites a failing loopback primary descriptor request, or a rejected desktop-local secondary backend), the destination atom waits on null and no toast appears. The issue does not define a bounded wait or a timeout, so this gap does not break the issue's stated requirement. Uncertainty: head ae3ff16 is newer than the previously reviewed head 4b00217. I did not read the incremental diff, so I cannot confirm whether the newer commits change the discovery gate or address the open review findings.

Full details: Out of Scope Changes check

Explanation

The changes in the whole-PR summary (merge base de0466f to head ae3ff16) implement the discovery-gated missing-environment check. They touch apps/web/src/providerAuthDelivery.ts, apps/web/src/connection/catalog.ts, apps/web/src/connection/platform.ts, packages/client-runtime/src/connection/{layer,registry,registry.test}.ts, and packages/client-runtime/src/platform/source.ts. The source type change to snapshots requires the mobile source update (apps/mobile/src/connection/platform.ts) and the threads-atoms.test.ts mock update. The scenario files support the change. The summary shows no changes to disconnect policy, fragment parsing, server flow validation, or desktop and native mobile callback paths, which the PR lists as excluded. The uncertainty noted for the linked-issue assessment also applies here: I did not read the incremental diff from 4b00217 to ae3ff16, so the verdict rests on the whole-PR summary and the head file content of providerAuthDelivery.ts.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4b00217 and ae3ff16.

Files selected for processing: 1

  • packages/client-runtime/src/connection/registry.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 20, 2026
juliusmarminge and others added 2 commits November 20, 2026 07:52
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Paired a second real environment, confirmed the synthetic ChatGPT callback reports failure while connected, removed that environment, then full-loaded the same return link. Chromium, 1280×800, light theme, fresh isolated state on both commits.

Before After
de0466fd80 ae3ff16369
Welcome remains silent for 40 seconds. Sign-in failure identifies the unavailable environment.
Before: no error after returning to a removed environment After: ChatGPT sign-in failure toast
Before recording After recording

Scenario source. scenarios:prove exited 0: failsOnBase=true, passesOnHead=true.

Not shown:

  • Permanent blocker: real first-party ChatGPT OAuth and the desktop automatic-return handoff require OAuth access unavailable on this VM; the reported synthetic return-link reproduction was verified.
  • Temporary discovery or connection failures and the failing-primary-descriptor case were not exercised.

@juliusmarminge juliusmarminge added takeover:needs-julius Takeover done; route gate says Julius decides and removed takeover:in-progress A takeover lead is working on this PR labels Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). takeover:needs-julius Takeover done; route gate says Julius decides vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ChatGPT sign-in returns silently when its environment has been removed

2 participants